package com.ideal.gpt.app.docqajob.localjob;

import java.io.File;
import java.util.Iterator;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import com.ideal.gpt.app.docqajob.QaParseJob.PerfixRemover;
import com.lzwork.utility.officeparser.ExcelLoader;
import com.lzwork.utility.officeparser.ExcelSaver;
import com.lzwork.utility.str.StrUtility;

/**
 * @author LiZheng
 * @date 2023年10月27日 上午10:48:05
 */

public class RemovePerfix extends ExcelSaver
{
	public static void main(String[] args)
	{
		PerfixRemover remover = new PerfixRemover(new File("V:/doc qa/remove_perfix.txt"));

		File input = new File("V:/doc qa/parse_2023口径库_train.xlsx");
		File output = new File("V:/doc qa/parse_2023口径库_train1.xlsx");

		Workbook wb = ExcelLoader.loadWorkBook(input);

		Sheet sheet = wb.getSheetAt(0);
		Iterator<Row> rowIt = sheet.rowIterator();

		while (rowIt.hasNext())
		{
			Row row = rowIt.next();
			if (row.getRowNum() == 0)
				continue;

			Cell cellQ = pickCellAt(row, 2);
			Cell cellA = pickCellAt(row, 3);

			String dataQ = ExcelLoader.getCellData(cellQ).getString();
			String dataA = ExcelLoader.getCellData(cellA).getString();

			dataQ = remover.replace(dataQ);
			if (!StrUtility.stringValid(dataQ))
				continue;

			dataA = remover.replace(dataA);

			cellQ.setCellValue(dataQ);
			cellA.setCellValue(dataA);
		}

		saveXlsFile(wb, output);
	}
}
